package com.example.activity.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Rain on 2016/4/21.
 */
public class Myadapter extends PagerAdapter {
    private List<View> allViews;

    public Myadapter(List<View> allViews) {
        this.allViews = allViews;
    }

    @Override
    public int getCount() {
        return allViews.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(allViews.get(position));
        return allViews.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(allViews.get(position));
    }
}
